package edu.chinasoft.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

/**
 * Servlet implementation class servlet02
 */
@WebServlet(name="myServlet02",value="/servlet/Servlet02")
public class Servlet02 extends HttpServlet {
	private static Logger logger = Logger.getLogger( Servlet02 .class);       

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		logger.debug("Servlet02>>>doGet start……");
		/*
		 * HttpServletRequest类里的方法getParameter的作用，只是获取请求里的内容
		 * 扩展该方法
		 * 不仅可以获取请求里的内容，而且还需要对返回的内容进行一下utf-8解码。
		 */
		logger.debug(request.getClass().getName());
		String content = request.getParameter("content");
		logger.debug("获取到的内容为："+content+"。");
		PrintWriter out=response.getWriter();
		out.write("获取到内容为："+content+"。");
		logger.debug("Servlet02>>>doGet end……");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		logger.debug("Servlet02>>>doPost start……");
		String content = request.getParameter("content");
		logger.debug("获取到的内容为："+content+"。");
		PrintWriter out = response.getWriter();
		out.write("获取到内容为："+content+"。");
		logger.debug("Servlet02>>>doPost end……");
		
	}

}
